// This software is released into the Public Domain.  See copying.txt for details.
package flca.osm.perst.impl;

import org.openstreetmap.osmosis.core.domain.v0_6.Node;

import flca.osm.perst.model.PNode;
import flca.osm.perst.util.TransactionHelper;

/**
 * Renders a node as xml.
 * 
 * @author Brett Henderson
 */
public class NodeWriter extends BaseWriter
{
	/**
	 * Creates a new instance.
	 * 
	 * @param elementName
	 *            The name of the element to be written.
	 * @param indentLevel
	 *            The indent level of the element.
	 */
	public NodeWriter(String elementName)
	{
	}

	/**
	 * Writes the node.
	 * 
	 * @param node
	 *            The node to be processed.
	 */
	public void process(Node aOsmNode)
	{
		int lat = (int) (aOsmNode.getLatitude() * 1E6);
		int lon = (int) (aOsmNode.getLongitude() * 1E6);
		
		PNode node = new PNode((int) aOsmNode.getId(), lat, lon);

		getRoot().nodePk.put(node);
		getRoot().nodeLat.put(node);
		
		TransactionHelper.INSTANCE.incNodes();
	}

}
